<?php
// +----------------------------------------------------------------------
// |  [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-present http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Released under the MIT License.
// +----------------------------------------------------------------------
// | Author: 老猫 <thinkcmf@126.com>
// +----------------------------------------------------------------------

namespace app\meeting\controller;

use cmf\controller\AdminBaseController;
use think\Db;

class ZhengController extends AdminBaseController
{
    public function index()
    {
        $where   = [];
        $where[] = ['title', 'like', '%' . input('keyword', '') . '%'];
        $data    = Db::table('ims_hc_meet')
            ->where($where)
            ->paginate(10);
        $page    = $data->render();
        $list    = $data->toArray();

        $this->assign('list', $list['data']);
        $this->assign('page', $page);
        return $this->fetch();
    }

    /*
      * lists
      * @param
      * $return
      */
    public function lists()
    {
        if (input('meeting_id')) {
            session('MEETING_ID', input('meeting_id'));
        }
        $where[] = ['type', '=', 2];
        $where[] = ['meeting_id', '=', session('MEETING_ID')];
        $where[] = ['order_no', 'like', '%' . input('order_no', '') . '%'];
        $data    = Db::table('ims_hc_meet_order')
            ->where($where)
            ->paginate();
        $page    = $data->render();
        $list    = $data->toArray();

        $this->assign('list', $list['data']);
        $this->assign('page', $page);
        return $this->fetch();
    }

    /*
     * detail
     * @param
     * $return
     */
    public function detail()
    {

        $id      = input('id');
        $info    = Db::table('ims_hc_meet_order')->find($id);
        $where[] = ['order_no', '=', $info['order_no']];

        $goods = Db::table('ims_hc_meet_order_goods')
            ->where($where)
            ->select()->toArray();
        foreach ($goods as $k => $v) {
            if ($v['remark']) {
                $a                   = json_decode(stripslashes(($v['remark'])), 1);
                $goods[$k]['remark'] = $a;
            }
        }
        $this->assign('info', $info);
        $this->assign('goods', $goods);
        return $this->fetch();
    }
}
